|
|
|
|
|
|
|
Figure 16.12
Approximating a vertex normal by averaging the adjacent face normals. |
|
|
|
|
|
|
|
|
Example program Gouraud draws spheres with Gouraud shading. Figure 16.13 shows a sphere made of 100 polygons. The image is much smoother than those produced by the programs described earlier in this chapter. The edges of the polygons are still visible along the outline of the sphere, however. These edges give the sphere a lumpy appearance. |
|
|
|
|
|
|
|
|
If you look very closely at Figure 16.13, you can also see several faint pale traces running vertically and horizontally across the surface of the sphere. Program Gouraud uses linear interpolation to calculate values for the points within a polygon. That makes the colors of those points blend smoothly. |
|
|
|
|
|
|
|
|
The speed of change in the interpolation may change at polygon edges, however. In this case, the colors vary linearly, but the surface is actually curved. This difference produces the small light areas. If you add a few more polygons to the sphere, this problem shrinks until it is not noticeable. Figure 16.14 shows program Gouraud displaying a sphere with more data points. The lighter areas are no longer visible. |
|
|
|
|
|
|
|
|
Many programs, though not program Gouraud, drop the specular reflection terms from the lighting model when they use this shading method. Gouraud shading calculates only colors at polygon vertexes and uses them to calculate the interior points' colors. |
|
|
|
|
|
|
|
|
Unless a vertex normal just happens to fall near the mirror direction for the viewing position, the specular term does not contribute significantly. If the polygons are relatively large, as they are in Figure 16.13, it is unlikely that a vertex normal will point in the mirror direction. If it does, it greatly brightens the surrounding polygons, producing an abnormally large specular highlight. |
|
|
|
|
|
|
|
|
You can see this effect in Figure 16.13. The sphere is slightly brighter in the upper left, but there is no specular highlight. In Figure 16.14, the size of the polygons is small enough that some of the vertex normals point in the mirror direction, so they produce a specular highlight. The polygons are small, so the highlight has a reasonably normal appearance. |
|
|
|
|
|